feat(openviking-plugin): native Session+Search integration with memory-first retrieval and observable fallback#2
Open
mczabca-boop wants to merge 6 commits intosteven1522:feature/plugin-systemfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR continues the OpenViking direction from TinyAGI#127 and remains stacked on #1 and #2 lineage (TinyAGI#127 -> #1 -> #2).
It integrates TinyClaw with OpenViking native Session + Search flow while preserving legacy markdown fallback, and pluginizes OpenViking context handling so core queue processing is no longer OpenViking-hardcoded.
What this PR adds
OpenViking context/session/search/writeback logic is moved behind the TinyClaw plugin system.
Core queue-processor now calls generic plugin lifecycle hooks:
onSessionReset
beforeModel
afterModel
onSessionEnd
plus onStartup / onHealth
When OpenViking plugin is disabled, TinyClaw runs normally without OpenViking calls.
Create/reuse session via stable mapping:
(channel, senderId, agentId) -> openviking_session_id
Write user/assistant messages to native session.
Commit on reset.
Keep fallback writeback path explicit and observable.
Prefer typed retrieval from memory/resource/skill.
Memory-first composition for injected context.
Structured short snippets for prompt injection (instead of large raw turn blocks).
Legacy markdown path (active.md / *.md) is still supported.
Fallback reasons are explicitly logged.
Legacy path is managed inside plugin logic (not core flow branches).
Native session write/commit success/failure logs.
Retrieval hit distribution logging (memory/resource/skill).
Explicit fallback reason + diagnostics logging.
Native prefetch dump for debugging:
prefetch_dump_native_latest.txt
Existing OpenViking feature flags remain compatible.
Existing user-visible context injection format is preserved.
Telegram/WhatsApp/Discord message pipeline behavior remains unchanged.
Key files touched
queue-processor.ts
plugins.ts
index.ts
prefetch.ts
session-map.ts
openviking-prefetch.ts (compat re-export)
openviking-session-map.ts (compat re-export)
types.ts
test-openviking-context-plugin.js
openviking-tool.ts
openviking-tool.js
setup-wizard.sh
daemon.sh
Compatibility / rollback
Feature flags (compatible with existing behavior):
TINYCLAW_OPENVIKING_CONTEXT_PLUGIN=0 (disable OpenViking context plugin entirely)
TINYCLAW_OPENVIKING_SESSION_NATIVE=1
TINYCLAW_OPENVIKING_SEARCH_NATIVE=1
TINYCLAW_OPENVIKING_PREFETCH=1
TINYCLAW_OPENVIKING_AUTOSYNC=1
If native/plugin flags are disabled, behavior falls back to non-OpenViking / legacy-compatible path.
Validation notes
Build passes:
npm run build:main
Regression passes:
npm run test:prefetch-parser
New pluginization integration tests pass:
npm run test:openviking-plugin
covers:
plugin disabled: no OpenViking calls
plugin enabled: native session + search + context injection
plugin failure: fallback path still works and is observable
Risk / follow-up
OpenViking latency (prefetch/commit) is environment-sensitive; timeout tuning may still be needed.
With stacked PR merge progression, diff should further collapse to OpenViking incremental changes only.